<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\OrdersSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '贷款列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="orders-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加订单', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

            // 'order_id',
            // 'user_id',
            // 'order_type',
        [
        "attribute" => "贷款方式",
        "value" => function ($model) { 
            if($model->order_type == 1){
                return '<p>急速贷款</p>';
            }else{
                return '<p>大额贷</p>';
            }

        },
        "format" => "raw",
        ],

        'order_name',
            // 'order_image',
        array(
            'attribute' => '图片',
            'format' => 'html',
            'value'=>function($data) { 
                return Html::img($data->order_image, ['width'=>'100']); },
                ),
        [
        "attribute" => "跳转链接",
        "value" => function ($model) { 
            return '<a href="'.$model->order_goto_url.'">点击跳转'.'</a>'; 
        },
        "format" => "raw",
        ],

            // 'order_goto_url:url',
            // 'order_hint_name',
        'order_rate_name',
        'order_day_rate',
            // 'order_desc',
            // 'order_num',
        'order_money',
        'order_sort',

        [
        "attribute" => "上下架",
        "value" => function ($model) { 
            return '<a href="'.Yii::$app->urlManager->createUrl("/orders/updatestatus")."&status=".($model->status == 0?'1':'0')."&id=".($model->order_id). ($model->status == 0?'">下架':'">上架'). '</a>';     
            
            
        },
        "format" => "raw",
        ],


        ['class' => 'yii\grid\ActionColumn'],
        ],
        ]); ?>
    </div>
